/**
 * @author: 團長
 * @date: 2014-2-12-下午5:48:55
 */
package net.loyintean.pearlshell.task.bus;

import java.util.List;
import java.util.concurrent.FutureTask;

import net.loyintean.pearlshell.base.model.IResult;


/**
 * Task executor. This service executes tasks concurrently, and encapsulates the
 * result or exception in IResult.
 * 
 * @author 團長
 * @since 2014-2-12
 * @version 1.0.0
 */
public interface ITaskExecuteService<T> {

	/**
	 * Executes tasks concurrently, and encapsulates the result or exception in
	 * IResult.
	 * <p>
	 * If any task in tasks failed or throws exception, the service should try
	 * to cancel anothers.
	 * 
	 * @author 團長
	 * @since 2014-2-17
	 * @param tasks
	 *            the concurrent tasks to be execute.
	 * @param result
	 *            the result of tasks. It also be used as return value.
	 * @return the execute result of tasks. It reuses the input paramenter
	 *         instance 'result'
	 * 
	 */
	public IResult<T> executeTasks(List<FutureTask<T>> tasks, IResult<T> result);
}
